package sk.openit.hibernate.entities;

// Generated 17.8.2011 17:02:48 by Hibernate Tools 3.4.0.CR1

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;


/**
 * Address generated by hbm2java
 */
@Entity
@Table(name = "Address", catalog = "skolenie")
@NamedQueries(
		{@NamedQuery(
				name = "Address.findAll", 
				query = "SELECT a FROM Address a"), 
		 @NamedQuery(
				 name = "Address.findByZipCode", 
				 query = "SELECT a FROM Address a WHERE a.zipCode = :zipCode")
		}
)
public class Address {
	private Integer id;
	private String street;
	private String town;
	private String zipCode;
	private Set persons = new HashSet(0);

	public Address() {
	}

	public Address(int id) {
		this.id = id;
	}

	public Address(Integer id, String street, String town, String zipCode,
			Set<Person> persons) {
		this.id = id;
		this.street = street;
		this.town = town;
		this.zipCode = zipCode;
		this.persons = persons;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "ID", unique = true)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "Street", length = 100)
	public String getStreet() {
		return this.street;
	}

	public void setStreet(String street) {
		this.street = street;
	}

	@Column(name = "Town", length = 50)
	public String getTown() {
		return this.town;
	}

	public void setTown(String town) {
		this.town = town;
	}

	@Column(name = "ZipCode", length = 20)
	public String getZipCode() {
		return this.zipCode;
	}

	public void setZipCode(String zipCode) {
		this.zipCode = zipCode;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "address")
	public Set<Person> getPersons() {
		return this.persons;
	}

	public void setPersons(Set persons) {
		this.persons = persons;
	}

	@Override
	public String toString() {
		return String.format("Address [id=%s, street=%s, town=%s, zipCode=%s]",
				id, street, town, zipCode);
	}

}
